/**
 * Created by lvzj on 2015/6/16.
 */
var clientService = require('../../services/backoffice/backOffice-clientService');
var messageUtil = require('../../common/utils/messageUtil');
var toolUtil = require('../../common/utils/toolUtil');


exports.getAtCsList = function (req, res) {
    var input = req.body;
    clientService.getAtCsList(input, function (err, result) {
        if (err) {
            logger.error('Exception happened when getAtCsList ...!' + err.message);
            res.json(messageUtil.composeFailedMessage(req, err.message));
        } else {
            var result = {list: result[0], totalPage: result[1]};
            res.json(messageUtil.composeSucceededMessage(req, null, result));
        }
    });
};

exports.updateAtCsUpdate = function (req, res) {
    var input = req.body;
    clientService.updateAtCsUpdate(input, function (err, result) {
        if (err) {
            logger.error('Exception happened when updateAtCsUpdate ...!' + err.message);
            res.json(messageUtil.composeFailedMessage(req, err.message));
        } else {
            res.json(messageUtil.composeSucceededMessage(req, null, null));
        }
    })
};

exports.getSharedFeeds = function (req, res) {
    clientService.getSharedFeeds(req.params.contentId,req.params.category, req.params.userId, function (err, result) {

        if (err) {
            logger.error('Exception happened when getSharedFeeds ...!' + err.message);
            res.json(messageUtil.composeFailedMessage(req, err.message));
        } else {
            res.json(messageUtil.composeSucceededMessage(req, null, result));
        }
    });
}
